package com.dq.Week3.day13.homework;

import java.util.*;

public class PrintString {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入字符串");
        String print = scanner.nextLine();
        printStr(print);

    }

    private static void printStr(String print) {
        char[] chars = print.toCharArray();
        Map<Character, Integer> hm = new HashMap<>();

        for (char aChar : chars) {
            if(!hm.containsKey(aChar))
            {
                hm.put(aChar,1);
            }else {
                hm.put(aChar, hm.get(aChar)+1);//可以覆盖
            }
        }
        for(Character key: hm.keySet()){
            //hm.keySet()代表所有键的集合,进行格式化输出
            System.out.println(key + "====" + hm.get(key)+"(个)");
        }
    }
}
